import { get, post, put, del } from '@/utils/request';
import { 
  Department, 
  CreateDepartmentRequest, 
  UpdateDepartmentRequest, 
  PaginatedResponse 
} from './types';

// 部门管理相关 API
export const departmentsApi = {
  // 获取部门列表
  getDepartments: (params) => get('/departments', params),

  // 获取部门树形结构
  getDepartmentTree: () => get('/departments/tree'),

  // 获取单个部门
  getDepartment: (id) => get(`/departments/${id}`),

  // 创建部门
  createDepartment: (data) => post('/departments', data),

  // 更新部门
  updateDepartment: (id, data) => put(`/departments/${id}`, data),

  // 删除部门
  deleteDepartment: (id) => del(`/departments/${id}`),

  // 批量删除部门
  batchDelete: (ids) => del('/departments', { data: { ids } }),

  // 获取部门用户列表
  getDepartmentUsers: (id, params) => get(`/departments/${id}/users`, params),

  // 获取部门统计信息
  getStats: () => get('/departments/stats/overview'),

  // 获取所有部门选项
  getAllDepartments: () => get('/departments/options/all'),
}; 